#ifndef __TRACE_H__
#define __TRACE_H__

#ifdef _RUN_WINDOWS_
#include <crtdbg.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#pragma warning(disable : 4996)

#define TRACEMAXSTRING    1024
inline void Trace(const char* format, ...)
{
#ifdef _DEBUG
	static char szBuffer[TRACEMAXSTRING];
	va_list args;
	va_start(args, format);
	int nBuf;
	nBuf = _vsnprintf(szBuffer,
	                  TRACEMAXSTRING,
	                  format,
	                  args);
	va_end(args);

	_RPT0(_CRT_WARN, szBuffer);
#endif
}
#define TraceEx _snprintf(szBuffer,TRACEMAXSTRING,"%s(%d): ", \
    &strrchr(__FILE__,'\\')[1],__LINE__); \
    _RPT0(_CRT_WARN,szBuffer); \
    Trace

#else
inline void Trace(const char* format, ...)
{

}

#define TraceEx

#endif
#endif // __TRACE_H__
